<template>
  <view>
    <view class="search-list">
      <view>
        <view v-for="(item, i) in dataList" :key="i" class="search-item" @click="gotoDetail(dataList, item, i)">
          <view class="search-item-1">
            <uni-icons type="star" size="20"></uni-icons>
          </view>
          <view class="search-item-2">
            <view>{{item.title}}</view>
          </view>
          <view class="search-item-3">
            <uni-icons type="forward" size="20"></uni-icons>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
  export default {
    name: "my-list",
    props: {
      dataList: {
        type: Array
      },
    },
    data() {
      return {

      };
    },
    methods: {
      gotoDetail(dataList, item, j) {
        // 当前id
        var id = item.id;
        var idlist = []
        for (var i = 0, len = dataList.length; i < len; i++) {
          var temp = dataList[i];
          idlist.push(temp.id);
        }
        uni.navigateTo({
          url: '/pages/detail/detail?id=' + item.id + '&idlist=' + JSON.stringify(idlist) + '&i=' + j
        })
      }
    },
  }
</script>

<style lang="scss">
  .search-list {
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .search-item {
    width: 686rpx;
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-bottom: 2rpx solid #A6A6A6;
  }

  .search-item-1 {}

  .search-item-2 {
    padding: 30rpx;
  }

  .search-item-2 view {
    width: 540rpx;
    word-break: break-all;
    font-size: 26rpx;
    line-height: 40rpx;
    letter-spacing: 8rpx;
  }

  .search-item-3 {}
</style>